local i = 1
local j = 1
local list = {}
local rtn  = {}
repeat
    local stock = redis.call('hget','dxsd-goods-'..KEYS[i], 'stock')
    local leave = stock - ARGV[i]
    if leave < 0 then
        return -400
    end
    table.insert(list,leave)
    i = i + 1
until( KEYS[i] == nil )
repeat
    local res = redis.call('hset','dxsd-goods-'..KEYS[j], 'stock',list[j])
    table.insert(rtn, res)
    j = j + 1
until( KEYS[j] == nil )
return rtn